package com.infore.exchange.main.dao;

import com.infore.common.model.entity.exchange.TJobInfo;
import com.infore.common.model.entity.exchange.TTaskInfo;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * <p>
 * 任务信息表 Mapper 接口
 * </p>
 *
 * @author lijh
 * @since 2023-02-13
 */
@Mapper
@Component
public interface TTaskInfoMapper extends BaseMapper<TTaskInfo> {


    @Update(" update t_ex_task_info set task_state = #{status} where task_id=#{taskId}")
    int updateTaskStateById(@Param("taskId")  String taskId,@Param("status")  Integer status);

    @Update(" update t_ex_task_info set running_state = #{runningState} where task_id=#{taskId}")
    int updateTaskRunningStateById(@Param("taskId")  String taskId,@Param("runningState")  Integer runningState);

    @Update(" update t_ex_task_info set running_state =0 where 1=1")
    int resetAllTaskRunningState();

    @Select("<script>" +
            "select * from t_ex_task_info where task_id not in (select distinct task_id from t_ex_job_task_info) " +
            "</script>")
    List<TTaskInfo> notBindTask();

}
